package com.hp.web.controller.teach;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hp.common.annotation.Log;
import com.hp.common.enums.BusinessType;
import com.hp.teach.domain.TeachWeisheng;
import com.hp.teach.service.ITeachWeishengService;
import com.hp.framework.web.base.BaseController;
import com.hp.common.page.TableDataInfo;
import com.hp.common.base.AjaxResult;
import com.hp.common.utils.poi.ExcelUtil;

/**
 * 卫生 信息操作处理
 * 
 * @author hp
 * @date 2021-07-30
 */
@Controller
@RequestMapping("/teach/teachWeisheng")
public class TeachWeishengController extends BaseController
{
    private String prefix = "teach/teachWeisheng";
	
	@Autowired
	private ITeachWeishengService teachWeishengService;
	
	@RequiresPermissions("teach:teachWeisheng:view")
	@GetMapping()
	public String teachWeisheng()
	{
	    return prefix + "/teachWeisheng";
	}
	
	/**
	 * 查询卫生列表
	 */
	@RequiresPermissions("teach:teachWeisheng:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(TeachWeisheng teachWeisheng)
	{
		startPage();
        List<TeachWeisheng> list = teachWeishengService.selectTeachWeishengList(teachWeisheng);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出卫生列表
	 */
	@RequiresPermissions("teach:teachWeisheng:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TeachWeisheng teachWeisheng)
    {
    	List<TeachWeisheng> list = teachWeishengService.selectTeachWeishengList(teachWeisheng);
        ExcelUtil<TeachWeisheng> util = new ExcelUtil<TeachWeisheng>(TeachWeisheng.class);
        return util.exportExcel(list, "teachWeisheng");
    }
	
	/**
	 * 新增卫生
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存卫生
	 */
	@RequiresPermissions("teach:teachWeisheng:add")
	@Log(title = "卫生", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(TeachWeisheng teachWeisheng)
	{		
		return toAjax(teachWeishengService.insertTeachWeisheng(teachWeisheng));
	}

	/**
	 * 修改卫生
	 */
	@GetMapping("/edit/{wid}")
	public String edit(@PathVariable("wid") Integer wid, ModelMap mmap)
	{
		TeachWeisheng teachWeisheng = teachWeishengService.selectTeachWeishengById(wid);
		mmap.put("teachWeisheng", teachWeisheng);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存卫生
	 */
	@RequiresPermissions("teach:teachWeisheng:edit")
	@Log(title = "卫生", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(TeachWeisheng teachWeisheng)
	{		
		return toAjax(teachWeishengService.updateTeachWeisheng(teachWeisheng));
	}
	
	/**
	 * 删除卫生
	 */
	@RequiresPermissions("teach:teachWeisheng:remove")
	@Log(title = "卫生", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(teachWeishengService.deleteTeachWeishengByIds(ids));
	}
	
}
